package cn.sdhuijin.healthexam.activity;

import java.io.File;

import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;

/**
 * 精神病随访详细信息
 * 
 * 
 * @author houyuchun
 * 
 */
public class MentalVisitInfoActivity extends AbstractControlActivity implements
		OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_mental_visit_info);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		// 获取传递过来的sql语句
		String fileName = intent.getStringExtra("filename");
		initTextView();
		setTextViewValue(fileName);
		setButtonListener(this, R.id.btn_back);
	}

	@Override
	public void onClick(View v) {
		int clickId = (Integer) v.getId();
		switch (clickId) {
		case R.id.btn_back:
			finish();
			break;
		default:
			break;
		}
	}

	private void initTextView() {
		addTextView(R.id.txt_user_name, "姓名");
		addTextView(R.id.txt_identify_num, "身份证号");
		addTextView(R.id.txt_visit_date, "随访日期");
		addTextView(R.id.txt_weixianxing, "危险性_content");
		addTextView(R.id.txt_muqianzhengzhuang, "目前症状_content");
		addTextView(R.id.txt_muqianzhengzhuang_qita, "其它目前症状");
		addTextView(R.id.txt_zizhili, "自知力_content");
		addTextView(R.id.txt_shuimianqingkuang, "睡眠情况_content");
		addTextView(R.id.txt_yinshiqingkuang, "饮食情况_content");
		addTextView(R.id.txt_gerenshenghuoll, "个人生活料理_content");
		addTextView(R.id.txt_jiawulaodong, "家务劳动_content");
		addTextView(R.id.txt_shengchanldjgz, "生产劳动及工作_content");

		addTextView(R.id.txt_xuexinengli, "学习能力_content");
		addTextView(R.id.txt_shehuirenjijw, "社会人际交往_content");
		addTextView(R.id.txt_qingduzishi, "轻度滋事 ");
		addTextView(R.id.txt_zhaoshici, "肇事");
		addTextView(R.id.txt_zhaohuoci, "肇祸");
		addTextView(R.id.txt_zishaci, "自伤");
		addTextView(R.id.txt_zishaweisuici, "自杀未遂");
		addTextView(R.id.txt_guansuoqingkuang, "关锁情况_content");
		addTextView(R.id.txt_zhuyuanqingkuang, "住院情况_content");
		addTextView(R.id.txt_mocichuyuanshijian, "末次住院时间");
		addTextView(R.id.txt_shiyanshijc, "实验室检查_content");
		addTextView(R.id.txt_fuyaoyicongxing, "服药依从性_content");
		addTextView(R.id.txt_yaowubuliangfy, "药物不良反应_content");
		addTextView(R.id.txt_zhiliaoxiaoguo, "治疗效果_content");

		addTextView(R.id.txt_zhuanzhen, "转诊原因");
		addTextView(R.id.txt_zhuanzhenjigou, "机构及科别");
		addTextView(R.id.txt_yaowu1, "药物名称一");
		addTextView(R.id.txt_yongfa1, "药物一次数");
		addTextView(R.id.txt_meicijiliang1, "药物一用量");
		addTextView(R.id.txt_yaowu2, "药物名称二");
		addTextView(R.id.txt_yongfa2, "药物二次数");
		addTextView(R.id.txt_meicijiliang2, "药物二用量");
		addTextView(R.id.txt_yaowu3, "药物名称三");
		addTextView(R.id.txt_yongfa3, "药物三次数");
		addTextView(R.id.txt_meicijiliang3, "药物三用量");
		addTextView(R.id.txt_kangfucuoshi, "康复措施_content");
		addTextView(R.id.txt_kangfucuoshi_qita, "其它康复措施");
		addTextView(R.id.txt_suifangfenlei, "此次随访分类_content");
		addTextView(R.id.txt_xiacisuifangrq, "下次随访日期");
		addTextView(R.id.txt_visit_doctor, "随访医生签名");
	}

	/**
	 * 读取对应文件，设置各个控件值
	 * 
	 * @param fileName
	 *            文件名称
	 */
	private void setTextViewValue(String fileName) {
		try {
			File f = new File(Environment.getExternalStorageDirectory()
					.getPath() + "/health/" + fileName + ".txt");
			if (f.exists()) {
				controlManager.setPropertiesPath(f.getAbsolutePath());
				controlManager.toControl();
			} else {
				this.toastInformation(R.string.record_deleted);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
